package pack;

import java.io.Serializable;
import java.util.List;

import javax.ejb.EJB;
import javax.faces.application.ConfigurableNavigationHandler;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;

import dao.EmployeeDAORemote;
import dto.EmployeeDTO;

@ManagedBean(name = "secretaryBean")
@SessionScoped
public class secretaryBean implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	@EJB
	EmployeeDAORemote employeeDAO;
	
	List<EmployeeDTO> angajati;
	
	public void verifyS(){
		FacesContext fc = FacesContext.getCurrentInstance();
		EmployeeDTO eDTO = (EmployeeDTO)fc.getExternalContext().getSessionMap().get("loggedInUser");
		
		ConfigurableNavigationHandler nav 
			= (ConfigurableNavigationHandler) 
		fc.getApplication().getNavigationHandler();
		
		if (eDTO != null){
			if (eDTO.getRank() != 4){
				nav.performNavigation("home.xhtml");
			}
		}
		else {
			nav.performNavigation("home.xhtml");
		}
		//read();
		read();
	}
	
	public String read(){
		angajati = employeeDAO.findAllAngajati();
		this.setAngajati(angajati);
		return "";
	}

	public List<EmployeeDTO> getAngajati() {
		return angajati;
	}

	public void setAngajati(List<EmployeeDTO> angajati) {
		this.angajati = angajati;
	}
	

}
